package net.java.mediasystems.web.bean;

import java.io.Serializable;

import net.java.mediasystems.database.core.model.StorageContainer;
import net.java.mediasystems.database.core.service.StorageContainerService;

public class AddStorageContainerBean extends AbstractEmbededMetadataValueInputBean implements Serializable {

	private static final long serialVersionUID = 2994860735156273769L;
	
	private static final String METADATA_CATEGORY_FOR_STORAGE_CONTAINER = "STORAGE-CONTAINER";
	
	private String name;
	private int sizeInMb;
	
	private transient StorageContainerService storageContainerService;
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	String getMetadataCategory() {
		return METADATA_CATEGORY_FOR_STORAGE_CONTAINER;
	}
	
	/**
	 * Save the StorageContainer.
	 */
	public void saveStorageContainer() {
		StorageContainer storageContainer = new StorageContainer();
		storageContainer.setName(this.name);
		storageContainer.setSizeInMegaBytes(this.sizeInMb);
		storageContainer.setMetadataValues(grabSelectedMetadata());
		
		this.storageContainerService.addStorageContainer(storageContainer);
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getSizeInMb() {
		return sizeInMb;
	}

	public void setSizeInMb(int sizeInMb) {
		this.sizeInMb = sizeInMb;
	}

	public void setStorageContainerService(StorageContainerService storageContainerService) {
		this.storageContainerService = storageContainerService;
	}	
}
